package dao;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

import domain.Unit;
import domain.util.HibernateFactory;

public class UnitDAO {

	static SessionFactory fact = HibernateFactory.getSessionFactory();
	static Session session = fact.openSession();
	static Transaction transaction;
	
	public static boolean save(Unit unit) {
		try {
			transaction = session.beginTransaction();
			session.save(unit);
			transaction.commit();
			return true;
		} catch (Exception e) {
			transaction.rollback();
			return false;
		}	
	}
	
}
